<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=1.0, initial-scale=1.0">
  <title>Document</title>
</head>

<body>


  <h3 id='btn' onclick='javaScript:clickhandle'>点击发送</h3>

  <div id="content"></div>

  <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js">
  </script>
  <script>
    window.onload = function () {
      wx.ready(function () {
        wx.agentConfig({
          corpid: 'wwf861751e07fa2ed0', // 必填，企业微信的corpid，必须与当前登录的企业一致
          agentid: '1000007', // 必填，企业微信的应用id
          timestamp: '1634204547', // 必填，生成签名的时间戳
          nonceStr: 'AAA', // 必填，生成签名的随机串
          signature: '046023d46e3a600429a187f6fef72286cee48b41', // 必填，签名，见附录1
          jsApiList: ['agentConfig',
            'openUserProfile',
            'thirdPartyOpenPage',
            'shareToExternalContact'
          ], //必填
          success: function (res) {
            alert("成功回调")
            // 发起审批流程
            wx.invoke(
              "shareToExternalContact", {
              text: {
                content: "", // 文本内容
              },
              attachments: [
              ]
            },
              function (res) {
                if (res.err_msg ==
                  "shareToExternalContact:ok"
                ) { }
              });

          },
          fail: function (res) {
            alert("失败")
            if (res.errMsg.indexOf(
              'function not exist') > -
              1) {
              alert('版本过低请升级')
            }
          }
        });
      })

      document.getElementById("btn").onclick = function () {
        alert(JSON.stringify(wx));

        // document.getElementById("content").innerHTML = '';
      }
    }
  </script>
</body>

</html>